home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / execview.wnt < prev    next >
Text File  |  1996-03-17  |  2KB  |  80 lines

  1. #line 2 "osdep/execview.wnt"
  2. /*----------------------------------------------------------------------
  3.     Routine to execute command mailcap says is used to display MIME segment
  4.     under MS-Windows win32 interface
  5.  
  6.  The exported routine is:
  7.  
  8.     exec_mailcap_cmd -- 
  9.  
  10.  ----*/
  11.  
  12.  
  13. /* ----------------------------------------------------------------------
  14.    Execute the given 
  15.  
  16.   Args: cmd -- 
  17.     image_file --
  18.   
  19.      
  20.   ----*/
  21.  
  22. void
  23. exec_mailcap_cmd(cmd, image_file, needsterminal)
  24.     char *cmd;
  25.     char *image_file;
  26.     int   needsterminal; /* not used in Windows */
  27. {
  28.     STARTUPINFO        start_info;
  29.     PROCESS_INFORMATION    proc_info;
  30.     DWORD        exit_code;
  31.  
  32.     dprint(9, (debugfile, "run_viewer: command=%s\n", cmd)) ;
  33.  
  34.     cancel_busy_alarm(1);
  35.  
  36.     memset(&proc_info, 0, sizeof(proc_info));
  37.     memset(&start_info, 0, sizeof(start_info));
  38.     start_info.dwFlags        = STARTF_FORCEONFEEDBACK;
  39.     start_info.wShowWindow  = SW_SHOWNORMAL;
  40.  
  41.     if(CreateProcess(NULL, cmd, NULL, NULL, FALSE,
  42.              CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
  43.              NULL, NULL, &start_info, &proc_info) == TRUE){
  44.     q_status_message(SM_ORDER, 0, 4, "VIEWER command completed");
  45.     dprint (3, (debugfile, "CreatProcess(%s)  Success.\n", cmd));
  46.  
  47.         /* Arrange to have the file deleted when the viewer exits.  But
  48.      * if that fails, tell the user. */
  49.     if(mswin_ontask_del(proc_info.hProcess, image_file))
  50.       q_status_message1(SM_ORDER, 0, 4,
  51.               "Temp file %s created, but not deleted", image_file);
  52.     }
  53.     else{
  54.     int rc = (int) GetLastError();
  55.     unlink(image_file);
  56.     q_status_message2(SM_ORDER, 3, 4, "\007Can't start viewer. %s%s.",
  57.         (rc == 2 || rc == 3) ? "Viewer not found:  " :
  58.           (rc == 8) ? "Not enough memory" : "Windows error ",
  59.         (rc == 2 || rc == 3) ? cmd :
  60.           (rc == 8) ? "" : int2string(rc));
  61.     }
  62. }
  63.  
  64.  
  65. /* ----------------------------------------------------------------------
  66.    Execute the given test= cmd
  67.  
  68.   Args: cmd -- command to execute
  69.   Returns exit status
  70.   
  71.   ----*/
  72. int
  73. exec_mailcap_test_cmd(cmd)
  74.     char *cmd;
  75. {
  76.     return((WinExec(cmd, SW_SHOWMINNOACTIVE) < 32) ? 1 : 0);
  77. }
  78.  
  79.  
  80.